from selenium.webdriver.common.by import By
from selenium import webdriver
import time,pytest
@pytest.fixture()
def driver():
    driver=webdriver.Edge()
    driver.get('https://www.jiuxian.com/')
    driver.maximize_window()
    yield driver
    driver.quit()
def test_jiuxian(driver):
    driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]').click()
    time.sleep(2)
    dy1=driver.find_element(By.XPATH,'//*[@id="loginform"]/div/div/div/div/div[1]/div[1]/a[1]').text
    print(dy1)
    assert '帐号登录' == dy1
    driver.find_element(By.NAME,'uname').send_keys('15336710135')
    driver.find_element(By.NAME,'_pwd').send_keys('002816Hj')
    time.sleep(10)
    driver.find_element(By.XPATH,'//*[@id="save"]').click()
    time.sleep(2)

    driver.find_element(By.XPATH,'//*[@id="bindSub"]').click()
    time.sleep(2)
    driver.find_element(By.XPATH,'//*[@id="wd"]').send_keys('海之洋')
    time.sleep(2)
    driver.find_element(By.XPATH,'/html/body/div[3]/div/div[2]/div[1]/form/input[2]').click()
    time.sleep(2)
    driver.find_element(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img').click()
    time.sleep(2)
    driver.switch_to.window(driver.window_handles[-1])
    driver.find_element(By.XPATH,'//*[@id="addToCartForDetail"]').click()
    time.sleep(2)
    driver.find_element(By.XPATH,'//*[@id="u-buy-layId"]/div/div[3]/a[2]').click()
    time.sleep(2)


